import store from '~/store';
import {loopLeafs} from './menuConfig';

/**
 * 判断用户menuList是否包含该页面id
 * 可用于权限判断
 * @param {number} id 路由的id
 */
export function hasAuth(id) {
    const {user: {menuList}} = store.getState();
    let found = false;
    loopLeafs(menuList, id, () => {
        found = true;
    });

    return found;
}

export default hasAuth;
